package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPatrolCompletionForTeamView;
import com.cloudsigns.factorymanager2.engineering.model.IPatrolCompletionForTeamModel;
import com.cloudsigns.factorymanager2.engineering.model.PatrolCompletionForTeamModel;

/**
 * Created by tony on 2018/6/17.
 */

public class PatrolCompletionForTeamPresenter {
    private IPatrolCompletionForTeamView view;
    private IPatrolCompletionForTeamModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PatrolCompletionForTeamPresenter(IPatrolCompletionForTeamView view) {
        this.view = view;
        this.model = new PatrolCompletionForTeamModel();
    }

    public void patrolCompletionForTeam() {


        model.patrolCompletionForTeam(view.getOrderId(),
                new PatrolCompletionForTeamModel.OnPatrolCompletionForTeamListener() {
                    @Override
                    public void patrolCompletionForTeamSunccessed() {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.patrolCompletionForTeamSuccess();
                                view.hideLoading();
                            }
                        });
                    }

                    @Override
                    public void patrolCompletionForTeamFailed(final String desc) {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.patrolCompletionForTeamFailed(desc);
                                view.hideLoading();
                            }
                        });
                    }
                });

    }
}
